﻿using System;
using System.Collections.Generic;
using System.Text;
using AxDVROCXLib;

namespace HardwareLibrary.DVRLibrary
{
    public class DVRHelper
    {
        public AxDVROCXLib.AxDVROcx dvr;
        /// <summary>
        /// 初始化监控，退出时一定要关闭监控
        /// </summary>
        /// <param name="HWND">监控HWND</param>
        /// <param name="dwCardID">监控ID号</param>
        /// <returns>True初始化成功，False失败</returns>
        public bool DVRsInit(int HWND, int dwCardID)
        {
            dvr.HxnDVRInit(HWND);
            if (dvr.HxnDVRConnectDevice(dwCardID) == true)
            {
                dvr.HxnDVRSetLogoText("");
                dvr.HxnDVRShowLogo(true, 10, 230);
                dvr.HxnDVRShowDate(true, 0, 0);
                dvr.HxnDVRShowTime(true, 140, 0);
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool DVRsReset(int HWND, int dwCardID)
        {
            dvr.HxnDVRUnInit();
            return DVRsInit(HWND, dwCardID);
        }
        public bool UpdateDVRsLogos(string LogoText)
        {
            return dvr.HxnDVRSetLogoText(LogoText);
        }
        public bool SnapDVRsPic(String SaveFilePath)
        {
            if (dvr.HxnDVRIsConnected() == true)
            {
                return dvr.HxnDVRSaveToJpgFile(SaveFilePath, 80);
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 关闭监控
        /// </summary>
        public void CloseDVR()
        {
            dvr.HxnDVRUnInit();
        }
    }
}
